package CollectionDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo1 {
    public static void main(String[] args) {
        Collection<String>collection = new ArrayList<>();
        collection.add("aaa");
        collection.add("bbb");
        collection.add("ccc");
        //迭代器
        Iterator<String> iterator = collection.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
           // System.out.println(iterator.next());
            if(s.equals("aaa")){
                iterator.remove();
            }
        }
        System.out.println("-----------");
        //增强for
        for (String s : collection) {
            System.out.println(s);
        }
    }
}
